//
//  NSString+Extension.m
//  HSLuser
//
//  Created by shishi on 17/4/5.
//  Copyright © 2017年 石世彪. All rights reserved.
//

#import "NSString+Extension.h"

@implementation NSString (Extension)

- (NSString *)VerticalString{
    NSMutableString * str = [[NSMutableString alloc] initWithString:self];
    NSInteger count = str.length;
    for (int i = 1; i < count; i ++) {
        [str insertString:@"\n" atIndex:i*2 - 1];
    }
    return str;
}


- (CGSize)sizeWithFont:(UIFont *)font maxSize:(CGSize)maxSize
{
    NSDictionary *attrs = @{NSFontAttributeName : font};
    return [self boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
}


-(CGFloat)stringW:(NSString *)sizeW font:(NSInteger)font wsize:(NSInteger)wsize{
    NSDictionary *arrtibute = @{NSFontAttributeName:[UIFont systemFontOfSize:font]};
    CGSize size1 = [sizeW boundingRectWithSize:CGSizeMake(wsize, MAXFLOAT) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin |NSStringDrawingUsesFontLeading attributes:arrtibute context:nil].size;
    return size1.height;
}


-(CGFloat)stringH:(NSString *)sizeH font:(NSInteger)font hsize:(NSInteger)hsize{
    NSDictionary *arrtibute = @{NSFontAttributeName:[UIFont systemFontOfSize:font]};
    CGSize size = [sizeH boundingRectWithSize:CGSizeMake(MAXFLOAT, hsize) options:NSStringDrawingUsesLineFragmentOrigin attributes:arrtibute context:nil].size;
    return size.width;
}

@end
